//
//  AgentsTableViewCell.m
//  BaseFrame
//
//  Created by 孟学浩 on 2017/4/5.
//  Copyright © 2017年 com.mxh. All rights reserved.
//

#import "AgentsTableViewCell.h"

@interface AgentsTableViewCell()

@property (nonatomic,strong) UILabel *mainLabel;
@property (nonatomic,strong) UILabel *infoLabel;

@end

@implementation AgentsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
        self.separatorInset = UIEdgeInsetsZero;
        if ([self respondsToSelector:@selector(setLayoutMargins:)]) {
            self.layoutMargins = UIEdgeInsetsZero;
        }
        
        _mainLabel = [UILabel new];
        _mainLabel.font = DEF_FontSize_15;
        
        _infoLabel = [UILabel new];
        _infoLabel.font = DEF_FontSize_15;
        _infoLabel.textAlignment = NSTextAlignmentRight;
        
        [self.contentView addSubview:_mainLabel];
        [self.contentView addSubview:_infoLabel];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    _mainLabel.frame = CGRectMake(10, 0, SCREEN_WIDTH - 20, self.frame.size.height);
    _infoLabel.frame = CGRectMake(10, 0, SCREEN_WIDTH - 20, self.frame.size.height);
}

- (void)setDataDictionary:(NSDictionary *)dataDictionary{
    _dataDictionary = dataDictionary;
    _mainLabel.text = _dataDictionary[@"name"];
}

- (void)setState:(AgentsState)state{
    _state = state;
    switch (_state) {
        case AgentsState_address:{
            _infoLabel.text = _model.address;
        }break;
        case AgentsState_time:{
            _infoLabel.text = _model.registrationTime;
        }break;
        case AgentsState_loginCount:{
            _infoLabel.text = [NSString stringWithFormat:@"登录次数   %@",_model.loginNum];
        }break;
        default:break;
    }
}

- (void)setModel:(AgentModel *)model{
    _model = model;
    _mainLabel.text = _model.sName;
    _infoLabel.text = _model.address;
}

@end
